home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Text / WASTE / WASTE 1.1.2 Distribution / Pseudo-UPI for THINK Pascal / Components.p < prev    next >
Encoding:
Text File  |  1995-10-12  |  9.8 KB  |  285 lines  |  [TEXT/PJMM]

  1. unit Components;
  2.  
  3. { Pascal Interface to the Macintosh Libraries }
  4.  
  5. { Copyright © Apple Computer Inc. }
  6. { All Rights Reserved }
  7.  
  8. { Adapted for use with THINK Pascal 4.0.x by Marco Piovanelli }
  9.  
  10. interface
  11.     uses
  12.         Types;
  13.  
  14.     const
  15.  
  16. { gestalt constants (!!! transplanted from GestaltEqu.p !!!) }
  17.         gestaltComponentMgr = 'cpnt';
  18.  
  19. { Component Manager & component errors (!!! transplanted from Errors.p !!!) }
  20.         invalidComponentID = -3000;
  21.         validInstancesExist = -3001;
  22.         componentNotCaptured = -3002;
  23.         componentDontRegister = -3003;
  24.  
  25.         kAppleManufacturer = 'appl';                        { Apple supplied components }
  26.         kComponentResourceType = 'thng';
  27.  
  28.         kAnyComponentType = 0;
  29.         kAnyComponentSubType = 0;
  30.         kAnyComponentManufacturer = 0;
  31.         kAnyComponentFlagsMask = 0;
  32.  
  33.         cmpWantsRegisterMessage = $80000000;
  34.  
  35.         kComponentOpenSelect = -1;                            { ComponentInstance for this open }
  36.         kComponentCloseSelect = -2;                            { ComponentInstance for this close }
  37.         kComponentCanDoSelect = -3;                            { selector # being queried }
  38.         kComponentVersionSelect = -4;                            { no params }
  39.         kComponentRegisterSelect = -5;                            { no params }
  40.         kComponentTargetSelect = -6;                            { ComponentInstance for top of call chain }
  41.         kComponentUnregisterSelect = -7;                            { no params }
  42.  
  43. { Component Resource Extension flags }
  44.         componentDoAutoVersion = $00000001;
  45.         componentWantsUnregister = $00000002;
  46.         componentAutoVersionIncludeFlags = $00000004;
  47.         componentHasMultiplePlatforms = $00000008;
  48.  
  49. { Set Default Component flags }
  50.         defaultComponentIdentical = 0;
  51.         defaultComponentAnyFlags = 1;
  52.         defaultComponentAnyManufacturer = 2;
  53.         defaultComponentAnySubType = 4;
  54.         defaultComponentAnyFlagsAnyManufacturer = 0 + (defaultComponentAnyFlags + defaultComponentAnyManufacturer);
  55.         defaultComponentAnyFlagsAnyManufacturerAnySubType = 0 + (defaultComponentAnyFlags + defaultComponentAnyManufacturer + defaultComponentAnySubType);
  56.  
  57. { RegisterComponentResource flags }
  58.         registerComponentGlobal = 1;
  59.         registerComponentNoDuplicates = 2;
  60.         registerComponentAfterExisting = 4;
  61.  
  62.  
  63.     type
  64.         ComponentDescription = record
  65.                 componentType: OSType;                                    { A unique 4-byte code indentifying the command set }
  66.                 componentSubType: OSType;                                    { Particular flavor of this instance }
  67.                 componentManufacturer: OSType;                                    { Vendor indentification }
  68.                 componentFlags: LONGINT;                                { 8 each for Component,Type,SubType,Manuf/revision }
  69.                 componentFlagsMask: LONGINT;                                { Mask for specifying which flags to consider in search, zero during registration }
  70.             end;
  71.         ResourceSpec = record
  72.                 resType: OSType;                                    { 4-byte code  }
  73.                 resID: INTEGER;
  74.             end;
  75.         ComponentResource = record
  76.                 cd: ComponentDescription;                    { Registration parameters }
  77.                 component: ResourceSpec;                            { resource where Component code is found }
  78.                 componentName: ResourceSpec;                            { name string resource }
  79.                 componentInfo: ResourceSpec;                            { info string resource }
  80.                 componentIcon: ResourceSpec;                            { icon resource }
  81.             end;
  82.         ComponentResourcePtr = ^ComponentResource;
  83.         ComponentResourceHandle = ^ComponentResourcePtr;
  84.  
  85.         ComponentPlatformInfo = record
  86.                 componentFlags: LONGINT;                                { flags of Component }
  87.                 component: ResourceSpec;                            { resource where Component code is found }
  88.                 platformType: INTEGER;                                { gestaltSysArchitecture result }
  89.             end;
  90.         ComponentResourceExtension = record
  91.                 componentVersion: LONGINT;                                { version of Component }
  92.                 componentRegisterFlags: LONGINT;                                { flags for registration }
  93.                 componentIconFamily: INTEGER;                                { resource id of Icon Family }
  94.             end;
  95.         ComponentPlatformInfoArray = record
  96.                 count: LONGINT;
  97.                 platformArray: array[0..0] of ComponentPlatformInfo;
  98.             end;
  99.         ExtComponentResource = record
  100.                 cd: ComponentDescription;                    { registration parameters }
  101.                 component: ResourceSpec;                            { resource where Component code is found }
  102.                 componentName: ResourceSpec;                            { name string resource }
  103.                 componentInfo: ResourceSpec;                            { info string resource }
  104.                 componentIcon: ResourceSpec;                            { icon resource }
  105.                 componentVersion: LONGINT;                                { version of Component }
  106.                 componentRegisterFlags: LONGINT;                                { flags for registration }
  107.                 componentIconFamily: INTEGER;                                { resource id of Icon Family }
  108.                 count: LONGINT;                                { elements in platformArray }
  109.                 platformArray: array[0..0] of ComponentPlatformInfo;
  110.             end;
  111.         ComponentParameters = packed record
  112.                 flags: CHAR;                                    { call modifiers: sync/async, deferred, immed, etc }
  113.                 paramSize: CHAR;                                    { size in bytes of actual parameters passed to this call }
  114.                 what: INTEGER;                                { routine selector, negative for Component management calls }
  115.                 params: array[0..0] of LONGINT;                { actual parameters for the indicated routine }
  116.             end;
  117.         ComponentRecord = record
  118.                 data: array[0..0] of LONGINT;
  119.             end;
  120.         Component = ^ComponentRecord;
  121.  
  122.         ComponentInstanceRecord = record
  123.                 data: array[0..0] of LONGINT;
  124.             end;
  125.         ComponentInstance = ^ComponentInstanceRecord;
  126.  
  127.         ComponentResult = LONGINT;
  128.  
  129.         ComponentRoutineProcPtr = ProcPtr;  { FUNCTION ComponentRoutine(VAR cp: ComponentParameters; componentStorage: Handle): ComponentResult; }
  130.         ComponentRoutineUPP = UniversalProcPtr;
  131.  
  132.     const
  133.         uppComponentRoutineProcInfo = $000003F0; { FUNCTION (4 byte param, 4 byte param): 4 byte result; }
  134.  
  135.     function NewComponentRoutineProc (userRoutine: ComponentRoutineProcPtr): ComponentRoutineUPP;
  136.     inline
  137.         $2E9F;
  138.  
  139.     function CallComponentRoutineProc (var cp: ComponentParameters;
  140.                                     componentStorage: Handle;
  141.                                     userRoutine: ComponentRoutineUPP): ComponentResult;
  142.     inline
  143.         $205F, $4E90;
  144.  
  145.     type
  146.         ComponentRoutine = ComponentRoutineUPP;
  147.  
  148. {}
  149. {    The parameter list for each ComponentFunction is unique. It is }
  150. {    therefore up to users to create the appropriate procInfo for their }
  151. {    own ComponentFunctions where necessary.}
  152. {}
  153.         ComponentFunctionUPP = UniversalProcPtr;
  154.  
  155.  
  156.     function RegisterComponent (var cd: ComponentDescription;
  157.                                     componentEntryPoint: ComponentRoutineUPP;
  158.                                     global: INTEGER;
  159.                                     componentName: Handle;
  160.                                     componentInfo: Handle;
  161.                                     componentIcon: Handle): Component;
  162.     inline
  163.         $7001, $A82A;
  164.     function RegisterComponentResource (tr: ComponentResourceHandle;
  165.                                     global: INTEGER): Component;
  166.     inline
  167.         $7012, $A82A;
  168.     function UnregisterComponent (aComponent: Component): OSErr;
  169.     inline
  170.         $7002, $A82A;
  171.     function FindNextComponent (aComponent: Component;
  172.                                     var looking: ComponentDescription): Component;
  173.     inline
  174.         $7004, $A82A;
  175.     function CountComponents (var looking: ComponentDescription): LONGINT;
  176.     inline
  177.         $7003, $A82A;
  178.     function GetComponentInfo (aComponent: Component;
  179.                                     var cd: ComponentDescription;
  180.                                     componentName: Handle;
  181.                                     componentInfo: Handle;
  182.                                     componentIcon: Handle): OSErr;
  183.     inline
  184.         $7005, $A82A;
  185.     function GetComponentListModSeed: LONGINT;
  186.     inline
  187.         $7006, $A82A;
  188. { Component Instance Allocation and dispatch routines }
  189.     function OpenComponent (aComponent: Component): ComponentInstance;
  190.     inline
  191.         $7007, $A82A;
  192.     function CloseComponent (aComponentInstance: ComponentInstance): OSErr;
  193.     inline
  194.         $7008, $A82A;
  195.     function GetComponentInstanceError (aComponentInstance: ComponentInstance): OSErr;
  196.     inline
  197.         $700A, $A82A;
  198. { Direct calls to the Components }
  199.     function ComponentFunctionImplemented (ci: ComponentInstance;
  200.                                     ftnNumber: INTEGER): LONGINT;
  201.     inline
  202.         $2F3C, $2, $FFFD, $7000, $A82A;
  203.     function GetComponentVersion (ci: ComponentInstance): LONGINT;
  204.     inline
  205.         $2F3C, $0, $FFFC, $7000, $A82A;
  206.     function ComponentSetTarget (ci: ComponentInstance;
  207.                                     target: ComponentInstance): LONGINT;
  208.     inline
  209.         $2F3C, $4, $FFFA, $7000, $A82A;
  210. { Component Management routines }
  211.     procedure SetComponentInstanceError (aComponentInstance: ComponentInstance;
  212.                                     theError: OSErr);
  213.     inline
  214.         $700B, $A82A;
  215.     function GetComponentRefcon (aComponent: Component): LONGINT;
  216.     inline
  217.         $7010, $A82A;
  218.     procedure SetComponentRefcon (aComponent: Component;
  219.                                     theRefcon: LONGINT);
  220.     inline
  221.         $7011, $A82A;
  222.     function OpenComponentResFile (aComponent: Component): INTEGER;
  223.     inline
  224.         $7015, $A82A;
  225.     function CloseComponentResFile (refnum: INTEGER): OSErr;
  226.     inline
  227.         $7018, $A82A;
  228. { Component Instance Management routines }
  229.     function GetComponentInstanceStorage (aComponentInstance: ComponentInstance): Handle;
  230.     inline
  231.         $700C, $A82A;
  232.     procedure SetComponentInstanceStorage (aComponentInstance: ComponentInstance;
  233.                                     theStorage: Handle);
  234.     inline
  235.         $700D, $A82A;
  236.     function GetComponentInstanceA5 (aComponentInstance: ComponentInstance): LONGINT;
  237.     inline
  238.         $700E, $A82A;
  239.     procedure SetComponentInstanceA5 (aComponentInstance: ComponentInstance;
  240.                                     theA5: LONGINT);
  241.     inline
  242.         $700F, $A82A;
  243.     function CountComponentInstances (aComponent: Component): LONGINT;
  244.     inline
  245.         $7013, $A82A;
  246. { Useful helper routines for convenient method dispatching }
  247.     function CallComponentFunction (var params: ComponentParameters;
  248.                                     func: ComponentFunctionUPP): LONGINT;
  249.     inline
  250.         $70FF, $A82A;
  251.     function CallComponentFunctionWithStorage (storage: Handle;
  252.                                     var params: ComponentParameters;
  253.                                     func: ComponentFunctionUPP): LONGINT;
  254.     inline
  255.         $70FF, $A82A;
  256.     function DelegateComponentCall (var originalParams: ComponentParameters;
  257.                                     ci: ComponentInstance): LONGINT;
  258.     inline
  259.         $7024, $A82A;
  260.     function SetDefaultComponent (aComponent: Component;
  261.                                     flags: INTEGER): OSErr;
  262.     inline
  263.         $701E, $A82A;
  264.     function OpenDefaultComponent (componentType: OSType;
  265.                                     componentSubType: OSType): ComponentInstance;
  266.     inline
  267.         $7021, $A82A;
  268.     function CaptureComponent (capturedComponent: Component;
  269.                                     capturingComponent: Component): Component;
  270.     inline
  271.         $701C, $A82A;
  272.     function UncaptureComponent (aComponent: Component): OSErr;
  273.     inline
  274.         $701D, $A82A;
  275.     function RegisterComponentResourceFile (resRefNum: INTEGER;
  276.                                     global: INTEGER): LONGINT;
  277.     inline
  278.         $7014, $A82A;
  279.     function GetComponentIconSuite (aComponent: Component;
  280.                                     var iconSuite: Handle): OSErr;
  281.     inline
  282.         $7029, $A82A;
  283.  
  284. implementation
  285. end.